#include <iostream>
#include <fstream>
using namespace std;

//#define READ_FILE

char g_array[100][100];
int g_partialSum[100][100];

void calcPartialSum(int n)
{
	for (int row = 0; row < n; ++row)
	{
		g_partialSum[0][row] = g_array[0][row];
	}
	
	for (int line = 1; line < n; ++line)
	{
		for (int row = 0; row < n; ++row)
		{
			g_partialSum[line][row] = g_partialSum[line-1][row] + g_array[line][row];
		}
	}
}

inline int rowSum(int begLine, int endLine, int row)
{
	if (begLine == 0)
	{
		return g_partialSum[endLine][row];
	}
	else
	{
		return g_partialSum[endLine][row] - g_partialSum[begLine-1][row];
	}
}

int calcLines(int begLine, int endLine, int n) // calculate max sum started with begLine, ended with endLine
{
	int maxSum = 0x80000000;
	int preSum = rowSum(begLine, endLine, 0);
	for (int i = 1; i < n; ++i)
	{
		int s = rowSum(begLine, endLine, i);
		preSum = (preSum + s > s) ? (preSum + s) : s;
		maxSum = (maxSum > preSum) ? maxSum : preSum;
	}
	return maxSum;
}

int calc(int n)
{
	calcPartialSum(n);
	
	int max = 0x80000000;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i; j < n; ++j)
		{
			int sum = calcLines(i, j, n);
			if (sum > max)
			{
				max = sum;
			}
		}
	}
	return max;
}

int main()
{
#ifdef READ_FILE
	ifstream in("1074.input");
	if (!in) { in.open("../1074.input"); }
#else
	#define in cin
#endif

	int n;
	while (in >> n)
	{
		for (int line = 0; line < n; ++line)
		{
			for (int row = 0; row < n; ++row)
			{
				int v;
				in >> v;
				g_array[line][row] = (char)v;
			}
		}	
		
		int maxSum = calc(n);
		
		cout << maxSum << endl;
	}
	return 0;
}